import { Schedule } from 'react-apm-api';
import { Profiler, MemoryRecorder, ConsoleOutlet } from 'react-apm-core';
import { CpuPlugin, FpsPlugin, GcpPlugin, MemoryPlugin, MrtPlugin, TrafficPlugin, ScuPlugin, BootPlugin, JSEventLoopPlugin, MethodTracePlugin, trace } from 'react-apm-plugins';

export function launchDefaults() {
    return Promise.all([
        CpuPlugin,
        FpsPlugin,
        GcpPlugin,
        MemoryPlugin,
        MrtPlugin,
        TrafficPlugin,
        ScuPlugin,
        BootPlugin,
        JSEventLoopPlugin,
        MethodTracePlugin
    ].map(PluginType => {
        const plugin = new PluginType();
        const recorder = new MemoryRecorder();
        const outlet = new ConsoleOutlet();
        const profiler = new Profiler(plugin, recorder, outlet);
        return profiler.start({ boot: Schedule.Erupt, sampler: {} });
    }));
}